﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Users.aspx.cs" Inherits="DotNet.WebUI.ADO.Users" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>用户信息管理</title>
	<link rel="stylesheet" type="text/css" href="/CSS/themes/default/easyui.css"/>
	<link rel="stylesheet" type="text/css" href="/CSS/themes/icon.css"/>
	<script type="text/javascript" src="/JS/jquery-3.3.1.min.js"></script>
	<script type="text/javascript" src="/JS/jquery.easyui.min.js"></script>    
	<script type="text/javascript" src="/JS/easyui-lang-zh_CN.js"></script>
    <script>
        function OpenWin() {
            $("#dlgUsers").dialog("open");
            $("#dlgUsers").dialog("open").dialog("setTitle", "添加用户信息");
        }

        //保存数据
        function SaveData() {
            $.ajax({
                url: "../ADO/UsersAdd.ashx",
                data: {
                    LoginID: $("#txtLoginID").val(),
                    Name: $("#txtUserName").val(),
                    Depict: $("#txtDepict").val()
                },
                type: "post",
                dataType: "text",
                beforeSend: function (XMLHttpRequest) {
                    if ($('#txtLoginID').val() == "") {
                        $.messager.alert("系统提示", "请输入登录代码！", "info");
                        return false;
                    }
                    if ($('#txtName').val() == "") {
                        $.messager.alert("系统提示", "请输入姓名！", "info");
                        return false;
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest + "提交数据时错误，状态值：" + textStatus + ", 错误信息：" + errorThrown);
                },
                success: function (result) {
                    $.messager.alert("系统提示", "保存成功", "info");
                    $(".easyui-datagrid").datagrid("reload");
                    CloseDialog();
                }
            });
        }

        //关闭对话框
        function CloseDialog() {
            $("#dlgUsers").dialog("close");
        }
    </script>
</head>
<body>
    <div id="lay" class="easyui-layout" fit=true>
        <div region="center" title="用户信息管理" iconCls="icon-main" style="padding:5px">
            <table id="t_tool" cellspacing="2px" cellpadding="0" border="0" style="width: 100%">
                <tr>
                    <td valign="middle" nowrap align="left" class=spannone>
                        查询条件：<input id="txt_cx" name="txt_cx" type="text" />
                        <a href="#" id="a_cx" class="easyui-linkbutton" iconcls="icon-search">查询</a>
                    </td>
                    <td valign="middle" nowrap align="right">
                        <a href="#" onclick="OpenWin();return false;" id="a_add" class="easyui-linkbutton" iconcls="icon-add">增加</a>
                    </td>
                </tr>
            </table>

            <table class="easyui-datagrid" style="width:100%;height:500px" data-options="singleSelect:true,collapsible:true,url:'../ADO/UsersData.ashx',method:'get'">
                <thead>
                    <tr>
                        <th data-options="field:'LoginID',width:80">登录代码</th>
                        <th data-options="field:'Name',width:100">姓名</th>
                        <th data-options="field:'Depict', Export: true">说明</th>
                    </tr>
                </thead>
            </table>
        </div>

    </div>

    <div id="dlgUsers" class="easyui-dialog" style="width:550px; height:300px; padding:10px; margin:0 auto;" closed="true" toolbar="#tbTools">
                <table>
                    <tr>
                        <td>登录代码</td>
                        <td><input type="text" class="InputBox" id="txtLoginID" name="txtLoginID" maxlength="20" /></td>
                    </tr>
                    <tr><td>姓名</td>
                        <td><input type="text" class="InputBox" id="txtUserName" name="txtUserName"/></td></tr>
                    <tr><td>描述</td>
                        <td><textarea class="InputBox" id="txtDepict" name="txtDepict" style="height:88px;"></textarea></td></tr>
                </table> 
            <div id="tbTools">
			    <a href="#" onclick="SaveData()" class="easyui-linkbutton" plain="true" iconCls="icon-ok">保存</a>
			    <a href="#" onclick="CloseDialog()" class="easyui-linkbutton" plain="true" iconCls="icon-cancel">关闭</a>
	        </div>
	    </div>	
    </body>
</html>